<div class="head">
	<h2><?php __d('lilcart', 'Item list');?></h2>
	<div class="actions">[+] <?php echo $html->link(__d('lilcart', 'Add Item', true), array('action'=>'add')); ?></div>
</div>
<div class="index" id="ItemsIndexTable">
<table cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th>&nbsp;</th>
			<th class="left"><?php echo $paginator->sort(__d('lilcart', 'Title', true), 'title');?></th>
			<th><?php echo $paginator->sort(__d('lilcart', 'Price', true), 'price');?></th>
			<th><?php echo $paginator->sort(__d('lilcart', 'Discount', true), 'discount');?></th>
			<?php
				// new th for every language if available
				if ($p_lngs = (array)Configure::read('LilcartPlugin.languages')) {
					foreach ($p_lngs as $p_lng) {
						echo '<th class="center">';
						if ($flag_prefix = Configure::read('LilcartPlugin.l18nFlagUrl')) {
							echo $html->image($flag_prefix.$p_lng.'.png', array('style'=>'height:32px'));
						} else {
							echo $sanitize->html($p_lng);
						}
						echo '</th>';
					}
				} else {
					echo '<th class="actions">&nbsp;</th>';
				}
			?>
			<th class="actions">&nbsp;</th>
		</tr>
	</thead>
<?php
	$i = 0;
	foreach ($data as $item) {
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
?>
	<tr<?php echo $class;?>>
		<td class="center"><?php echo $html->image('thumbs'.DS.$item['Item']['id'].'.jpg', array('style'=>'width: 64px;')); ?></td>
		<td><?php echo $sanitize->html($item['Item']['title']); ?></td>
		<td class="center"><?php if (!is_null($item['Item']['price'])) printf('%.2f', $item['Item']['price']); ?>&nbsp;</td>
		<td class="center"><?php if (!is_null($item['Item']['discount'])) printf('%.1f', $item['Item']['discount']); ?>&nbsp;</td>
		<?php
			if (!empty($p_lngs)) {
				foreach ($p_lngs as $p_lng) {
					echo '<td class="center">';
					echo $html->link(__d('lilcart', 'Edit', true), array('action'=>'edit', $item['Item']['id'], 'lang'=>$p_lng));
					echo '</td>';
				}
			} else {
		?>
			<td class="actions center"><?php echo $html->link(__d('lilcart', 'Edit', true), array('action'=>'edit', $item['Item']['id'])); ?></td>
		<?php
			}
		?>
		<td class="actions center"><?php echo $html->link(__d('lilcart', 'Delete', true), array('action'=>'delete', $item['Item']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $item['Item']['id'])); ?></td>
	</tr>
<?php } ?>
	<tfoot>
		<tr>
			<td colspan="<?php echo sizeof($p_lngs)+7; ?>" class="paging">
				<?php echo $paginator->prev('<< '.__d('lilcart', 'previous', true), array('class'=>'prev'), null, array('class'=>'prev light'));?>
				<?php echo $paginator->next(__d('lilcart', 'next', true).' >>', array('class'=>'next'), null, array('class'=>'next light'));?>
				<?php
					echo '<div class="counter">'.$paginator->counter(array(
					'format' => __d('lilcart', 'Page <b>%page%</b> of <b>%pages%</b>, total <b>%count%</b> records.', true))).'</div>';
				?>
			</td>
		</tr>
	</tfoot>
</table>
</div>